Skip to content

feat(match-assignment): add atomic batch referee assignment by round#76

Merged
pol-rivero merged 4 commits intoUdL-EPS-SoftArch-Igualada:mainfrom
Ferranicu:feat/issue-66-batch-referee-assignment
Mar 4, 2026
Merged

feat(match-assignment): add atomic batch referee assignment by round#76
pol-rivero merged 4 commits intoUdL-EPS-SoftArch-Igualada:mainfrom
Ferranicu:feat/issue-66-batch-referee-assignment

Conversation

@Ferranicu
Copy link
Contributor

Closes #66
Implements atomic batch referee assignment per round, with full validation, intra-batch conflict detection, detailed failure reporting, and unit/Cucumber coverage.

Copilot AI review requested due to automatic review settings March 4, 2026 14:17
@udl-softarch udl-softarch bot added the pr-not-ready This PR cannot be merged until you have reviewed the code analysis results. label Mar 4, 2026
@udl-softarch
Copy link

udl-softarch bot commented Mar 4, 2026

Thank you for your PR @Ferranicu! Now, you should wait for the automated code analysis by CodeRabbit, Copilot and SonarQube.
Please review all warnings carefully, as some of them might be false positives.

Once you are confident that you have fixed all the detected issues and this PR is ready to be merged, add a comment with exactly one word: ready.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • New POST /matchAssignments/batch endpoint for atomic batch referee assignments with per-item results.
  • Bug Fixes / Improvements

    • Detects intra-batch conflicts and prevents partial updates.
    • Validation for rounds, roles, and item-level inputs; added ROUND_NOT_FOUND handling.
    • Richer error responses include per-item details plus timestamp and request path.
  • Tests

    • Added unit/integration scenarios for batch success and multiple failure modes.

Walkthrough

Adds a transactional POST /matchAssignments/batch endpoint, DTOs, service logic, exception/enriched error responses, and tests to perform all-or-nothing batch referee assignments with per-item validation and intra-batch conflict detection.

Changes

Cohort / File(s) Summary
Controller
src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.java
New POST /matchAssignments/batch handler assignRefereesBatch(...) that accepts BatchMatchAssignmentRequest, delegates to MatchAssignmentService.assignBatch(...), and returns BatchMatchAssignmentResponse.
Batch DTOs
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java, src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemRequest.java, src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java, src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemResponse.java
Adds request/response records for batch payloads with Jakarta Bean Validation; response validates processed count vs assignments size.
Service
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
Adds assignBatch(...), injects RoundRepository, implements parsing, per-item validation, referee resolution, intra-batch conflict detection, deterministic ordering, contextual exceptions, and atomic persistence via applyBatchAssignments.
Exceptions & Handler
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java, .../MatchAssignmentException.java, .../MatchAssignmentExceptionHandler.java
Adds ROUND_NOT_FOUND and DUPLICATE_MATCH_IN_BATCH codes; extends MatchAssignmentException with batch context fields (index, matchId, refereeId) and accessors; handler maps new codes and returns enriched ErrorResponse with BatchErrorDetails when present.
Unit Tests
src/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.java, src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
Adds controller tests for batch success and error mapping; updates service tests to include RoundRepository and multiple batch scenarios (success and various failures).
BDD Tests / Features
src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java, src/test/resources/features/MatchAssignment.feature
Extends Cucumber steps and feature scenarios to create rounds and batch matches, exercise batch assignment happy path, intra-batch availability conflict, invalid role case, and missing round case; integrates round state into test flow.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Code Style ⚠️ Warning Code violates 2-level indentation guideline with multiple files exceeding depth limit. MatchAssignmentService.java has lines at depth 3-6 with lambda expressions and nested statements lacking clear justification. Refactor deeply nested code by extracting lambda expressions into private methods, breaking method chains into intermediate variables, and simplifying conditional operators to maintain 2-level indentation.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(match-assignment): add atomic batch referee assignment by round' clearly and specifically summarizes the main change, matching the primary objective of implementing batch assignment functionality.
Description check ✅ Passed The description 'Closes #66. Implements atomic batch referee assignment per round, with full validation, intra-batch conflict detection, detailed failure reporting, and unit/Cucumber coverage.' is directly related to the changeset and captures the key objectives.
Linked Issues check ✅ Passed The PR implements all major requirements from issue #66: batch endpoint, per-item validation, intra-batch conflict detection, transactional behavior, detailed error responses, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #66: batch assignment DTOs, service logic, controller endpoint, exception handling, and comprehensive tests; no unrelated modifications detected.
Has Tests ✅ Passed Comprehensive tests cover batch assignment functionality with unit, controller, and end-to-end tests for success and failure cases including conflict detection and rollback.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for assigning referees to multiple matches within a round in one atomic (all-or-nothing) operation, including validation, intra-batch conflict detection, and API/error-response plumbing.

Changes:

  • Added POST /matchAssignments/batch endpoint with request/response DTOs for round-scoped batch assignment.
  • Implemented transactional batch assignment logic in MatchAssignmentService, including intra-batch overlap detection and detailed per-item failure metadata.
  • Added unit tests, controller tests, and Cucumber scenarios covering success, rollback on conflict, and rollback on invalid role.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java Implements transactional batch assignment, validations, and intra-batch overlap checks.
src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.java Exposes POST /matchAssignments/batch.
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java Defines batch request payload with bean validation.
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemRequest.java Defines per-item request DTO.
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java Defines batch response payload.
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemResponse.java Defines per-item response DTO.
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java Adds batch-aware error response structure with per-item details.
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java Extends exception to carry batch failure metadata (index/matchId/refereeId).
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java Adds ROUND_NOT_FOUND error code.
src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java Adds service-level tests for batch success and rollback scenarios.
src/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.java Adds controller tests for batch success and detailed error response.
src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java Adds Cucumber step defs to create rounds/matches and call batch endpoint.
src/test/resources/features/MatchAssignment.feature Adds Cucumber scenarios for batch assignment success and rollback cases.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 726ab8af-bc66-429c-8f4f-adfc01215d13

📥 Commits

Reviewing files that changed from the base of the PR and between 0051630 and 94e48a9.

📒 Files selected for processing (13)
  • src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemRequest.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemResponse.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java
  • src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.java
  • src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java
  • src/test/resources/features/MatchAssignment.feature

Copilot AI review requested due to automatic review settings March 4, 2026 14:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ae37f06b-21ae-4abe-aea5-782607fb56b9

📥 Commits

Reviewing files that changed from the base of the PR and between 94e48a9 and 09fe96a.

📒 Files selected for processing (9)
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java
  • src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java
  • src/test/resources/features/MatchAssignment.feature

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: defb32e0-7037-465f-8d33-e0e524c861c4

📥 Commits

Reviewing files that changed from the base of the PR and between 09fe96a and 9a61654.

📒 Files selected for processing (2)
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java

@Ferranicu
Copy link
Contributor Author

ready

@udl-softarch udl-softarch bot removed the pr-not-ready This PR cannot be merged until you have reviewed the code analysis results. label Mar 4, 2026
@udl-softarch udl-softarch bot requested a review from pol-rivero March 4, 2026 15:06
@udl-softarch
Copy link

udl-softarch bot commented Mar 4, 2026

This PR is now marked as ready to be merged.

@pol-rivero
Copy link
Member

Looks good to me. You just need to fix the sonarqube warnings.

Copilot AI review requested due to automatic review settings March 4, 2026 15:37
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@Ferranicu
Copy link
Contributor Author

@pol-rivero done, fixed the sonarqube warnings

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2ca81f72-d7c3-43dd-8b5e-030613082270

📥 Commits

Reviewing files that changed from the base of the PR and between 9a61654 and b601069.

📒 Files selected for processing (1)
  • src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment on lines +69 to +73
public BatchMatchAssignmentResponse assignBatch(String roundId, List<BatchMatchAssignmentItemRequest> assignments) {
Long parsedRoundId = parseIdOrThrow(roundId);
Round round = roundRepository.findById(parsedRoundId)
.orElseThrow(() -> new MatchAssignmentException(
MatchAssignmentErrorCode.ROUND_NOT_FOUND,
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assignBatch is doing parsing, de-duplication, ordering, DB lookups/locking, validation, conflict detection, persistence, and response mapping in one method. To keep control flow and testing manageable, consider extracting these phases into small private methods (e.g., parse+dedupe, load+validate candidates, build response) and keeping assignBatch as orchestration only.

Copilot generated this review using guidance from repository custom instructions.
@pol-rivero
Copy link
Member

@Ferranicu Perfect, thanks

@pol-rivero pol-rivero merged commit 7e9ad77 into UdL-EPS-SoftArch-Igualada:main Mar 4, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Add batch referee assignment for a round with conflict detection

3 participants